// pages/releaseIndex/releaseIndex.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    IsShopVideo: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // 自定义tabbar切换
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 2
      })
    };
    
    var FjLoginLog = wx.getStorageSync('FjLoginLog');
    var that = this
    var api_input = {
      uid: FjLoginLog.UID,
      upwd: FjLoginLog.UPwd
    }
    app.getDaoPost('api/FeijiuApp/Post_FJ_UserInfoByUID', api_input, function (r) {
      console.log(JSON.parse(app.aesDec(r.data)))
      if (r.code == 200) {
        var arr = JSON.parse(app.aesDec(r.data));
        that.setData({
          URankName: arr.URankName,
          JiFen: arr.JiFen,
          Mobile: arr.Uinfo[0].Mobile,
          IsShopVideo: arr.IsShopVideo,
          ShopVideoMess: arr.ShopVideoMess,
          ZuLinMess: arr.ZuLinMess
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  navRelease(e) {
    let id = e.currentTarget.dataset.id
    if (app.checkFjLogin()) {
      if (id == 1) {
        wx.navigateTo({
          url: '/packageB/pages/sellRelease/Acategorize/Acategorize?type=1',
        })
      } else if (id == 2) {
        wx.navigateTo({
          url: '/packageB/pages/sellRelease/Acategorize/Acategorize?type=2',
        })
      } else if (id == 3) {
        wx.navigateTo({
          url: '/packageB/pages/quickRelease/quickIndex/quickIndex',
        })
      } else if (id == 4) {
        if (this.data.IsShopVideo != 1) {
          app.tishi(this.data.ShopVideoMess);
          return false;
        } else {
          app.tishi('此功能仅限app使用');
          return false;
        }
      } else if (id == 5) {
        wx.navigateTo({
          url: '/packageB/pages/biddingAuctionRelease/biddingAuctionIndex/biddingAuctionIndex',
        })
      } else if (id == 6) {
        // if (this.data.IsShopVideo != 1) {
        //   app.tishi(this.data.ZuLinMess);
        //   return false;
        // }
        wx.navigateTo({
          url: '/packageB/pages/leaseRelease/leaseIndex/leaseIndex',
        })
      }
    } else {
      if (id == 3) {
        wx.navigateTo({
          url: '/packageB/pages/quickRelease/quickIndex/quickIndex',
        })
        return false;
      }
      wx.navigateTo({
        url: '../../pages/login/index'
      });
    }
  }
})